const koa = require("koa");
const app = new koa();
const static = require("koa-static");
const path = require("path");
app.use(static(path.join(__dirname,"public")));
let initConfig = require('./init/config')

//登录拦截
app.use(async (ctx,next)=>{
    if(ctx.path=="/login" || ctx.path=="/doLogin") {
        await next();
    } else {
        if(ctx.cookies.get("username")) {
            await next();
        } else {
            ctx.redirect("/login");
        }
    }
}) 
initConfig(app);
app.listen(8080);
